/**
 *
 */
package com.ybkj.daijia.server.service.impl;

import com.ybkj.daijia.server.mapper.DriverChoseLevelZhuanxianMapper;
import com.ybkj.daijia.server.model.DriverChoseLevelZhuanxian;
import com.ybkj.daijia.server.service.DriverChoseLevelZhuanxianService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultDriverChoseLevelZhuanxianService implements DriverChoseLevelZhuanxianService {

    @Autowired
    private DriverChoseLevelZhuanxianMapper driverChoseLevelZhuanxianMapper;

    @Transactional(rollbackFor = Exception.class)
    public DriverChoseLevelZhuanxian insertRecord(
        DriverChoseLevelZhuanxian driverChoseLevelZhuanxian) {

        driverChoseLevelZhuanxianMapper.insertRecord(driverChoseLevelZhuanxian);

        return driverChoseLevelZhuanxian;

    }


    @Override
    public DriverChoseLevelZhuanxian findByDriverAndLevelAndLine(Long driverId, Long driverLevelId,
        Long lineId, Integer lineType) {

        return driverChoseLevelZhuanxianMapper
            .selectByDriverAndLevelAndLine(driverId, driverLevelId, null, lineType);
    }

    @Override
    public DriverChoseLevelZhuanxian findByDriverAndLine(Long driverId, Long lineId,
        Integer lineType) {

        return driverChoseLevelZhuanxianMapper.selectByDriverAndLine(driverId, null, lineType);
    }

    @Override
    public List<DriverChoseLevelZhuanxian> findByDriver(Long driverId) {

        return driverChoseLevelZhuanxianMapper.selectByDriver(driverId);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteByDriverAndLine(Long driverId, Integer lineType) {
        driverChoseLevelZhuanxianMapper.deleteByDriverAndLine(driverId, lineType);
    }


    @Transactional(rollbackFor = Exception.class)
    public void deleteByDriver(Long driverId) {

        driverChoseLevelZhuanxianMapper.deleteByDriver(driverId);

    }


}